package com.shamine.kuaiqiao.blink.gallery

import android.widget.TextView
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.shamine.kuaiqiao.blink.data.Gallery
import com.shamine.kuaiqiao.blink.R
import com.shamine.kuaiqiao.blink.basic.GlideApp

class GalleryAdapter(private val context: GalleryActivity): BaseQuickAdapter<Gallery,BaseViewHolder>(R.layout.item_gallery,null) {

    override fun convert(holder: BaseViewHolder, gallery: Gallery) {
        GlideApp.with(context)
                .load(gallery.cover?.fileUrl)
                .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(holder.getView(R.id.cover))
        holder.setText(R.id.title,gallery.title)
        (holder.getView(R.id.date) as TextView).text = gallery.createdAt.substring(0,10)
        (holder.getView(R.id.count) as TextView).text = gallery.size.toString()
    }
}